<template>
  <div>
    <div class="PhotoWall">
      <ul class="menu">
        <li class="back">
          <i
            class="iconfont icon-xitongfanhui"
            @click="$router.push('/home/singUp')"
          ></i>
        </li>
        <li class="share">
          <i class="iconfont icon-wujiaoxingkong"></i>
          <i class="iconfont icon-31zhuanfa" @click="showShare = true"></i>
          <i class="iconfont icon-qita"></i>
        </li>
      </ul>

      <!--   @/assets/icon_baoming/jx1.jpeg -->
      <img class="picWall" :src="Details.info.school_cover" alt="" />
    </div>

    <!-- 详情信息 -->
    <div class="main">
      <div class="detail">
        <div class="name">
          <span>{{ Details.info.school_name }}</span>
          <div class="vip">
            <i v-show="true" class="iconfont icon-vip5"></i>
          </div>
        </div>
        <div class="attestation">
          <span v-show="true"
            ><i class="iconfont icon-zhengque1 icontrue"></i> 驾校工商认证</span
          >
          <span v-show="true"
            ><i class="iconfont icon-zhengque1 icontrue"></i> 驾校运营认证</span
          >
        </div>
        <div class="score">
          {{ Details.info.school_score }}
          <span>分</span>
        </div>
        <!-- 驾校标签 -->
        <div class="tag">
          <span class="typeTag" v-for="(item, i) in labelArray" :key="i">{{
            item
          }}</span>
        </div>

        <!-- 绝对定位电话 -->
        <div class="call">
          <callPhone></callPhone>
        </div>
        <!-- 驾校地址 -->
        <ol class="addressInfo">
          <li class="address">
            <div class="addressText">
              {{ Details.info.school_address }}
            </div>
            <div class="km">
              <i class="iconfont icon-wxbdingwei iconkm"></i>
              距您{{}}km
            </div>
          </li>
          <li class="position">
            <i class="iconfont icon-dingwei iconPosition"></i>
            位置
          </li>
        </ol>
      </div>
    </div>
    <div style="height: 10px; background-color: gray; opacity: 0.2"></div>

    <div class="course">
      <h3>班型</h3>
      <ul class="card">
        <li class="card-left">
          <img src="@/assets/icon_baoming/kunkun.jpg" alt="" />
        </li>
        <li class="card-right">
          <div class="tit">
            <strong>{{ Details.info.licensetype }}学车班</strong>
            <div>
              2180
              <span>￥2580</span>
            </div>
          </div>
          <div class="call2">
            <callPhone class="size"></callPhone>
          </div>
        </li>
      </ul>
    </div>

    <!-- 咨询按钮 -->
    <div class="consult">
      <button>免费咨询</button>
      <button>电话咨询</button>
    </div>

    <!-- 转发弹出 -->
    <van-share-sheet
      v-model:show="showShare"
      title="立即分享给好友"
      :options="options"
      @select="onSelect"
      round
    />
  </div>
</template>

<script>
import { ref, reactive, onMounted } from "vue";
import { showToast } from "vant";
import callPhone from "@/components/callPhone";
import { useRoute } from "vue-router";
import httpApi from "@/http";

//获取路由管理器对象
export default {
  setup() {
    const route = useRoute();
    let Details = reactive({
      info: {},
    });
    let labelArray = reactive([]); //驾校标签
    const ByIdSchool = () => {
      let school_id = Number(route.params.schoolId);
      console.log(school_id);
      httpApi.schoolApi
        .ByIdSchoolDetail({ school_id: school_id })
        .then((res) => {
          Details.info = res.data.data.result[0];
          console.log(Details.info);
          labelArray.push(...Details.info.schoollabel.split("/"));
        });
    };


    /* 分享转发 */
    const showShare = ref(false);
    const options = [
      { name: "微信", icon: "wechat" },
      { name: "朋友圈", icon: "wechat-moments" },
      { name: "微博", icon: "weibo" },
      { name: "QQ", icon: "qq" },
    ];

    const onSelect = (option) => {
      showToast(option.name);
      showShare.value = false;
    };

    onMounted(() => {
      ByIdSchool();
    });
    return {
      ref,
      Details,
      reactive,
      options,
      onSelect,
      showShare,
      onMounted,
      ByIdSchool,
      labelArray,
    };
  },
};
</script>

<style lang="scss" scoped>
.PhotoWall {
  position: relative;
  margin-bottom: calc(30vh - 40px);
  > .menu {
    height: 40px;
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0 15px;
    position: relative;
    z-index: 500;
    .back {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: rgba(0, 0, 0, 0.7);
      width: 25px;
      height: 25px;
      border-radius: 50%;
      > i {
        font-size: 15px;
        color: white;
      }
    }
    .share {
      line-height: 40px;
      display: flex;
      justify-content: space-around;
      > i {
        color: white;
        background-color: rgba(0, 0, 0, 0.7);
        width: 25px;
        line-height: 25px;
        text-align: center;
        margin-left: 10px;
        border-radius: 50%;
      }
    }
  }
  .picWall {
    position: absolute;
    top: 0;
    width: 100%;
    height: 30vh;
    z-index: 10;
    object-fit: cover;
  }
}
.main {
  background-color: white;
  width: 100%;
  height: calc(70h + 13px);
  border-top-right-radius: 13px;
  border-top-left-radius: 13px;
  padding: 10px;
  position: relative;
  top: -13px;
  z-index: 300;

  .call {
    position: absolute;
    right: 18px;
    top: 30px;
  }
  > .detail {
    /* 驾校名字及认证图标 */
    > .name {
      line-height: 40px;
      display: flex;
      align-items: center;
      > span {
        font-size: 20px;
        font-weight: bold;
        margin-right: 5px;
      }
      > .vip {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        border-radius: 3px;
        background-color: #42bafc;
        > i {
          font-size: 20px;
          color: #fff;
        }
      }
    }
    /* 工商及运营认证 */
    .attestation {
      line-height: 20px;
      > span {
        font-size: 12px;
        margin-right: 5px;
        .icontrue {
          font-size: 15px;
          color: green;
        }
      }
    }

    /* 驾校评分 */
    .score {
      line-height: 24px;
      color: orangered;
      font-size: 18px;
      > span {
        font-size: 12px;
      }
    }

    /* 驾校标签 */
    .tag {
      width: 70%;
      line-height: 40px;
      overflow: hidden;
      text-overflow: ellipsis;

      .typeTag {
        padding: 3px 4px;
        color: var(--color-blue-600);
        font-size: 15px;
        background-color: rgba(27, 159, 221, 0.5);
        margin-left: 5px;
        border-radius: 4px;
      }
    }
    /* 地址信息 */
    .addressInfo {
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
      .address {
        display: flex;
        flex-direction: column;
        > .addressText {
          flex:1;
          margin-right: 20px;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: pre-wrap;
          font-size: 16px;
          line-height: 20px;
          color: black;
          margin-bottom: 6px;
        }
        > .km {
          font-size: 14px;
          color: gray;

          > .iconkm {
            font-size: 14px;
            margin-right: 2px;
          }
        }
      }
      .position {
        display: flex;
        align-items: center;
        flex-direction: column;
        font-size: 12px;
        margin-right: 10px;
        .iconPosition {
          font-size: 30px;
          margin-bottom: 5px;
        }
      }
    }
  }
}
/* 班型 */
.course {
  padding: 0px 10px;

  > h3 {
    padding: 10px 0;
    background-color: #fff;
    text-align: center;
  }
  .card {
    display: flex;
    padding: 5px 10px;
    .card-left {
      padding: 5px 0;
      width: 30%;
      margin-right: 10px;
      > img {
        width: 100%;
        height: 90px;
        border-radius: 8px;
        overflow: hidden;
        object-fit: cover;
      }
    }
    .card-right {
      flex: 1;
      display: flex;
      justify-content: space-between;
      > .tit {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        > strong {
          font-size: 20px;
          color: black;
          margin-top: 10px;
        }
        > div {
          color: rgb(197, 34, 34);
          font-weight: bold;
          font-size: 28px;
          padding-bottom: 10px;
          &::before {
            content: "￥";
            font-size: 18px;
          }
          > span {
            text-decoration: line-through;
            color: gray;
            font-size: 0.6em;
          }
        }
      }

      /* 咨询电话 */
      .call2 {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-right: 5px;
        ::v-deep .iconCall {
          font-size: 40px;
        }
      }
    }
  }
}
/* 咨询按钮 */
.consult {
  height: 70px;
  box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.5);
  display: flex;
  position: sticky;
  align-items: center;
  bottom: 0;
  background-color: #fff;
  justify-content: space-around;
  > button {
    width: 43%;
    border-radius: 100px;
    height: 46px;
    color: white;
    &:nth-child(1) {
      background-color: #3dd5f3;
    }
    &:nth-child(2) {
      background-color: var(--color-blue-600);
    }
  }
}

/* 触发菜单 */
.menu-active {
  background-color: #fff;
  height: 60px;
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  align-items: center;
  padding: 0 15px;
  .back {
    display: flex;
    justify-content: center;
    color: black;
    align-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    > i {
      font-size: 20px;
      color: black;
    }
  }
  .share {
    line-height: 40px;
    display: flex;
    justify-content: space-around;
    > i {
      color: black;
      width: 30px;
      font-size: 20px;
      line-height: 30px;
      text-align: center;
      margin-left: 10px;
      border-radius: 50%;
    }
  }
}
</style>
